import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {

  id?: number,
  projectId?: number,
  workOrderTitle?: string,
  projectName?: string,
  workOrderType?: number,
  workOrderStatus?: number,
  waiting?: string,
  createdByName?: string,
  createdAt?: string,
  sellMethod: number,
  processId: number,
  handleUid: number,
  workOrderDesc: string,
  noticeType: number,
  workOrderImg: string,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/business/work-order/v2/work-orders';
const Url = '/business/work-order/v2/work-order';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
//撤销工单 
export const workordercancel = (data?: object) => {
  return http.request<commonResult<any>>("put", "/business/work-order/v2/work-order/cancel", {
    data
  });
};
//处理工单
export const workorderhandle = (data?: object) => {
  return http.request<commonResult<any>>("put", "/business/work-order/v2/work-order/deal", {
    data
  });
}
//根据项目id获取人员
/** 2.5.7.1 根据项目id查询授权用户（下拉选择框） */
export const authorizeusersa = (params?: object) => {
  return http.request<commonResult<any>>("get", "/business/project/v2/project/authorize-user", {
    params
  });
}
/** 2.5.7.2 查询用户项目权限 */
export const getUserProjectRole = (params?: object) => {
  return http.request<commonResult<any>>("get", "/business/project/v2/project/project-perms", {
    params
  });
}